﻿<UserControl x:Class="NAudioWpfDemo.ControlPanel"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="Auto" Width="Auto" xmlns:my="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">

    <UserControl.Resources>
        <ControlTemplate x:Key="TextBoxTemplate" TargetType="TextBoxBase">
            <my:ListBoxChrome Background="{TemplateBinding Control.Background}" BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="{TemplateBinding Control.BorderThickness}" Name="Bd" RenderFocused="{TemplateBinding UIElement.IsKeyboardFocusWithin}" RenderMouseOver="{TemplateBinding UIElement.IsMouseOver}" SnapsToDevicePixels="True">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    
                    <ScrollViewer Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                    <Button Grid.Column="1" IsEnabled="{TemplateBinding IsEnabled}">
                        <Image Source="Resources\arrow_right_green.ico" Height="15"/>
                    </Button>
                </Grid>
            </my:ListBoxChrome>
            <ControlTemplate.Triggers>
                <Trigger Property="UIElement.IsEnabled" Value="False">
                    <Setter Property="my:ListBoxChrome.Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                    <Setter Property="Control.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        
        <CollectionViewSource Source="{Binding SongList}" x:Key="SongList" />
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>
    
    <Grid Margin="5" HorizontalAlignment="Stretch">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <Grid Grid.Column="0" HorizontalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            
            <Label Content="Connection URI" VerticalAlignment="Center" />
            <TextBox Grid.Column="1" Text="{Binding Mode=TwoWay, Path=ConnectionUri, UpdateSourceTrigger=PropertyChanged}" ToolTip="hostname:port[?udp=port]" HorizontalAlignment="Stretch" VerticalAlignment="Center" Template="{StaticResource TextBoxTemplate}" KeyDown="ConnectionUriTextBox_KeyDown" ButtonBase.Click="ConnectionUriButton_Click" />
        </Grid>

        <StackPanel Orientation="Horizontal" Grid.Column="1" Margin="5 0 10 0" >
            <Label Content="Song Name" VerticalAlignment="Center" />
            <ComboBox Width="140" VerticalAlignment="Center" ItemsSource="{Binding Source={StaticResource SongList}}" SelectedItem="{Binding SongName}" />
        </StackPanel>

        <StackPanel Orientation="Horizontal" Grid.Column="2">
            <Button Command="{Binding StopCommand}" Margin="2" ToolTip="Stop">
                <Rectangle Fill="DarkBlue" Width="15" Height="15" Margin="3" RadiusX="2" RadiusY="2"/>
            </Button>
            <Button Command="{Binding PlayStreamCommand}" Margin="2" ToolTip="Play">
                <Path Fill="DarkGreen" Margin="3" Width="15" Height="15" Data="M 0,0 L 1,1 L 0,2 Z" Stretch="Fill" StrokeLineJoin="Round"/>
            </Button>
        </StackPanel>

        <StackPanel Name="DisabledButtons" Orientation="Horizontal" Grid.Column="2" Panel.ZIndex="1">
            <Button Margin="2" ToolTip="Stop" IsEnabled="False">
                <Rectangle Fill="Gray" Width="15" Height="15" Margin="3" RadiusX="2" RadiusY="2"/>
            </Button>
            <Button Margin="2" ToolTip="Play" IsEnabled="False">
                <Path Fill="Gray" Margin="3" Width="15" Height="15" Data="M 0,0 L 1,1 L 0,2 Z" Stretch="Fill" StrokeLineJoin="Round"/>
            </Button>
        </StackPanel>
    </Grid>
</UserControl>
